home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / amitcp / kern / amiga_netdb.h < prev    next >
C/C++ Source or Header  |  1994-04-06  |  5KB  |  176 lines

  1. #ifndef AMIGA_NETDB_H
  2. #define AMIGA_NETDB_H
  3. /* $Id: amiga_netdb.h,v 3.2 1994/04/06 15:37:12 too Exp $
  4.  *
  5.  * kern/amiga_netdb.h --- local NetDB functions
  6.  *
  7.  * Author: ppessi <Pekka.Pessi@hut.fi>
  8.  *
  9.  * Copyright (c) 1993 OHT-AmiTCP/IP Group,
  10.  *                    Helsinki University of Technology, Finland.
  11.  *                    All rights reserved.
  12.  *
  13.  * Created      : Thu Apr 22 12:05:05 1993 ppessi
  14.  * Last modified: Wed Apr  6 18:06:05 1994 too
  15.  *
  16.  * $Log: amiga_netdb.h,v $
  17.  * Revision 3.2  1994/04/06  15:37:12  too
  18.  * Added flag ACF_PRIVONLY
  19.  *
  20.  * Revision 3.1  1994/03/26  09:44:06  too
  21.  * Added ACCESS control data items and defines.
  22.  * Added function prototype for (fixed) service entry query
  23.  * and netdb deinitialization placeholder.
  24.  *
  25.  * Revision 1.11  1993/05/29  20:55:59  jraja
  26.  * Removed declaration of netdb path name.
  27.  *
  28.  * Revision 1.10  1993/05/16  19:24:03  jraja
  29.  * Changed structure names:
  30.  * NameServerNode => NameserventNode, nameserver => nameservent,
  31.  * DomainNode => DomainentNode, domainname => domainent.
  32.  *
  33.  * Revision 1.9  1993/05/16  00:14:28  jraja
  34.  * Changed the nameserver ent value from sockaddr_in to in_addr.
  35.  *
  36.  * Revision 1.8  1993/05/15  12:57:25  ppessi
  37.  * Added netinet/in.h into includes. Changed struct domain to struct domainname
  38.  * (there was a name clash)
  39.  *
  40.  * Revision 1.7  93/05/15  10:48:45  10:48:45  too (Tomi Ollila)
  41.  * Silly style error fixed (nsn_addr -> ns_addr)
  42.  * 
  43.  * Revision 1.6  93/05/15  10:36:57  10:36:57  too (Tomi Ollila)
  44.  * Some cosmetic changes for consistency
  45.  * 
  46.  * Revision 1.5  1993/05/14  23:07:56  ppessi
  47.  * Fixed bugs. Added a NameserverEnt node type
  48.  *
  49.  * Revision 1.4  93/05/14  11:38:10  11:38:10  ppessi (Pekka Pessi)
  50.  * Removed private information. Added DNS and domain lists. 
  51.  * Changed locking mechanism. Added (untested) RESET feature.
  52.  * 
  53.  * Revision 1.3  93/05/05  16:10:12  16:10:12  puhuri (Markus Peuhkuri)
  54.  * Fixes for final demo.
  55.  * 
  56.  * Revision 1.2  93/05/04  12:45:46  12:45:46  jraja (Jarno Tapio Rajahalme)
  57.  * Changed keyword names to avoid collisions with data names(e.g. host name).
  58.  * 
  59.  * Revision 1.1  93/04/28  21:57:22  21:57:22  ppessi (Pekka Pessi)
  60.  * Initial revision
  61.  * 
  62.  */
  63.  
  64. #ifndef NETDB_H
  65. #include <netdb.h>
  66. #endif
  67.  
  68. #ifndef IN_H
  69. #include <netinet/in.h>
  70. #endif
  71.  
  72. /* Access control table item */
  73. struct AccessItem {
  74.   UWORD    ai_flags;
  75.   UWORD    ai_port;
  76.   ULONG    ai_host;
  77.   ULONG ai_mask;
  78. };
  79.  
  80. /* Access control flags */
  81. #define ACF_ALLOW    0x01
  82. #define ACF_LOG        0x02
  83. #define ACF_PRIVONLY    0x04 /* 0 as port matches for privileged ports only */
  84. #define ACF_CONTINUE    (1 << 15)
  85.  
  86. /* AC table temporary buffer size */
  87. #define TMPACTSIZE    0x4000 
  88.  
  89. /* NetDataBase */
  90. struct NetDataBase {
  91.   struct SignalSemaphore ndb_Lock;
  92.   struct MinList         ndb_Hosts;
  93.   struct MinList         ndb_Networks;
  94.   struct MinList         ndb_Services;
  95.   struct MinList         ndb_Protocols;
  96.   struct MinList         ndb_NameServers;
  97.   struct MinList         ndb_Domains;
  98.   LONG             ndb_AccessCount; /* tmp var, but reduces code size */
  99.   struct AccessItem *     ndb_AccessTable;
  100. };
  101.  
  102. extern struct NetDataBase *NDB;
  103.  
  104. /* Locking macros for NDB */
  105. #define LOCK_W_NDB(ndb) (ObtainSemaphore(&(ndb)->ndb_Lock))
  106. #define LOCK_R_NDB(ndb) (ObtainSemaphoreShared(&(ndb)->ndb_Lock))
  107. #define UNLOCK_NDB(ndb) (ReleaseSemaphore(&(ndb)->ndb_Lock))
  108. #define ATTEMPT_NDB(ndb) (AttemptSemaphore(&(ndb)->ndb_Lock))
  109.  
  110. /*
  111.  * GenEnt has the common part of all NetDataBase Nodes below
  112.  */
  113. struct GenentNode {
  114.   struct MinNode gn_Node;
  115.   short          gn_EntSize;
  116.   struct {
  117.     char dummy[0];
  118.   }              gn_Ent;
  119. };
  120.  
  121. /* NetDataBase Nodes */
  122. struct HostentNode {
  123.   struct MinNode hn_Node;
  124.   short          hn_EntSize;
  125.   struct hostent hn_Ent;
  126. };
  127.  
  128. struct NetentNode {
  129.   struct MinNode nn_Node;
  130.   short          nn_EntSize;
  131.   struct netent  nn_Ent;
  132. };
  133.  
  134. struct ServentNode {
  135.   struct MinNode  sn_Node;
  136.   short           sn_EntSize;
  137.   struct servent  sn_Ent;
  138. };
  139.  
  140. struct ProtoentNode {
  141.   struct MinNode  pn_Node;
  142.   short           pn_EntSize;
  143.   struct protoent pn_Ent;
  144. };
  145.  
  146. struct NameserventNode {
  147.   struct MinNode  nsn_Node;
  148.   short           nsn_EntSize;
  149.   struct nameservent {
  150.     struct in_addr ns_addr;
  151.   } nsn_Ent;
  152. };
  153.  
  154. struct DomainentNode {
  155.   struct MinNode  dn_Node;
  156.   short           dn_EntSize;
  157.   struct domainent {
  158.     char *d_name;
  159.   } dn_Ent;
  160. };
  161. /*
  162.  * netdatabase calls for some AmiTCP/IP functions
  163.  */
  164. struct ServentNode * findServentNode(struct NetDataBase * ndb,
  165.                      const char * name, const char * proto);
  166.  
  167. /*
  168.  * Read NetDB...
  169.  */
  170. LONG do_netdb(struct CSource *cs, UBYTE **errstrp, struct CSource *res);
  171. LONG reset_netdb(struct CSource *cs, UBYTE **errstrp, struct CSource *res);
  172. LONG init_netdb(void);
  173. void netdb_deinit(void);
  174.      
  175. #endif /* AMIGA_NETDB_H */
  176.